package cn.tedu.tw;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class App {
    public static void main(String[] args) throws Exception {
        // TODO
        // 1. 通过反射得到 CustomerService 的实例 c
        // 2. 调用实例 c 的 printRandomString 方法并正确输出结果
        Class<?> C =Class.forName("cn.tedu.tw.CustomerService");
        Class<?> U =Class.forName("cn.tedu.tw.UserService");
        Object CustomerService = C.newInstance();
        Object UserService = U.newInstance();
        Field service = C.getDeclaredField("service");
        service.setAccessible(true);
        service.set(CustomerService,UserService);
        Method printRandomString = C.getMethod("printRandomString");
        printRandomString.invoke(CustomerService);
    }
}
